package nspel

import "github.com/aliyun/alibaba-cloud-sdk-go/sdk"

var accessKeyId string
var accessKeySecret string
var templateMsm0 string
var templateMsm1 string
var signName string

var client *sdk.Client

func configMsm() {
	var data = struct {
		AccessKeyId     string `json:"accessKeyId"`
		AccessKeySecret string `json:"accessKeySecret"`
		TemplateMsm0    string `json:"templateMsm0"`
		TemplateMsm1    string `json:"templateMsm1"`
		SignName        string `json:"signName"`
	}{}
	loadConfigJson("config/msm.json", &data)
	accessKeyId = data.AccessKeyId
	accessKeySecret = data.AccessKeySecret
	templateMsm0 = data.TemplateMsm0
	templateMsm1 = data.TemplateMsm1
	signName = data.SignName
	var err error
	client, err = sdk.NewClientWithAccessKey("default", accessKeyId, accessKeySecret)
	if err != nil {
		panic(err)
	}
}

func GetSmsClient() *sdk.Client {
	return client
}

func ReconnectSms() (err error) {
	client, err = sdk.NewClientWithAccessKey("default", accessKeyId, accessKeySecret)
	return
}

func GetSignName() string {
	return signName
}

func GetTemplateMsm(Type int) string {
	switch Type {
	case 0:
		return templateMsm0
	case 1:
		return templateMsm1
	}
	return ""
}
